#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#define int long long
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
int a[N];
int ans;
//int g[110][110];
vector<vector<int>> g(110,vector<int>(110));
void solve()
{
    int n,m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int op,a,b,c;
        cin >> op >> a >> b >> c;
        if(op == 1) 
        {
            g[a][b] += c;
        } 
        if(op == 2)
        {
            g[a][b] -= c;
        }
       int res = 0;
       for(int i = 1; i <= n; i++)
       {
          for(int j = 1; j <= n; j++)
          res = max(res, g[i][j]); 
       }
       cout << res << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    /*  int t;
     cin >> t; */
    while(t -- ) solve();
    return 0;
}